package com.crop.back.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.crop.back.common.utils.ResultBean;
import com.crop.back.entity.Feedback;
import com.crop.back.service.FeedbackService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/back/feedback")
@RequiredArgsConstructor
public class FeedbackController {
    private final FeedbackService feedbackService;

    @PostMapping("/add")
    public ResultBean<String> addFeedback(@RequestBody Feedback feedback) {
        feedbackService.save(feedback);
        return ResultBean.ok("反馈成功");
    }

    @GetMapping("/list")
    public ResultBean<Page<Feedback>> getFeedbackList(
        @RequestParam(required = false) String contactType,
        @RequestParam(required = false) String contactInfo,
        @RequestParam(defaultValue = "1") Integer page,
        @RequestParam(defaultValue = "10") Integer size) {
        
        Page<Feedback> result = feedbackService.getFeedbackList(contactType, contactInfo, page, size);
        return ResultBean.ok(result);
    }
}
